import axios from 'axios'
//导入message
import { Message } from 'element-ui'
const _axios = axios.create({
  baseURL: 'http://www.liulongbin.top:3008'
})
_axios.interceptors.request.use(
  config => {
    return config
  },
  error => {
    return Promise.reject(error)
  }
)
//在这做一个全局的错误处理
_axios.interceptors.response.use(
  res => {
    if (res.data.code === 0) {
      return res.data
    } else {
      Message.error(res.data.message)
      return Promise.reject(res.data.message)
    }
  },
  error => {
    return Promise.reject(error)
  }
)
export default _axios
